<script>
export default {
	onLaunch: function () {
		//getlatestoneseorder
		// console.log('App Launch')
		//消息推送功能
		// #ifdef APP-PLUS
		let qtyDecimal = uni.getStorageSync('myconfig')['qtyDecimal']
		Vue.prototype.globalData = {
			qtyDecimal:qtyDecimal==''||qtyDecimal==undefined?2:qtyDecimal,   //全局变量
			toSecPage:'',	//扫描标识 默认空
			default_stock_id:7674,//默认原料仓
		};
		let tm=false;
		// //点击消息
		/*plus.push.addEventListener('click',(msg)=>{
			//console.log(msg,'点击消息');
			//console.log(msg)
			// onLaunch 生命周期里，页面跳转有问题,跳不过去
			// 应该是页面还没加载，加上定时后，就可以了； 
			clearTimeout(tm)
			tm = setTimeout(()=>{
				uni.navigateTo({
					url:msg.payload.page
				})
			},1500)
		},false)

		//监听消息
		plus.push.addEventListener('receive',(msg)=>{
			clearTimeout(tm)
			plus.nativeUI.toast( msg.payload.content );
		},false)
		
		setInterval(()=>{
			 let latest_seorder_id = uni.getStorageSync('latest_seorder_id')
			 let flag = false
				this.$Api.getlatestoneseorder().then(res=>{
					if(res.data.code == 1){
						let data = res.data.data
						if(latest_seorder_id==''){
							flag = true
							uni.setStorageSync('latest_seorder_id',data.FInterID)
							uni.setStorageSync('latest_seorder_redpoint',true)
						}else{
							if(data.FInterID>latest_seorder_id){
								uni.setStorageSync('latest_seorder_id',data.FInterID)
								uni.setStorageSync('latest_seorder_redpoint',true)
								flag = true
							}
						}
						if(flag){
							let options = {cover:false,title:'销售订单报表',payload:{page:'/pages/seorder/listbywifi'}}
							plus.push.createMessage('日期:'+data.FDate+'单号:'+data.FBillNo+'客户:'+data.orgName+'货物:'+data.FName,options.payload,options)//+' 剩余数量:200'
						}
					}
				})
		},60000)*/
		// #endif
	},
	onShow: function () {
		// console.log('App Show')
		//获取设备唯一标识
		getDeviceInfo();
	},
	onHide: function () {
		// console.log('App Hide')
	},
	onLoad() {
		
	}
}

//获取设备唯一标识
function getDeviceInfo(){
	plus.device.getInfo({
		success:function(e){
			var uuid = uni.getStorageSync('uuid');
			if(uuid==''){
				uni.setStorageSync('uuid',e.imei);//e.uuid
			}
			//console.log('getDeviceInfo success: '+JSON.stringify(e));
		},
		fail:function(e){
			//console.log('getDeviceInfo failed: '+JSON.stringify(e));
		}
	});
}
</script>

<style lang="less">
/*每个页面公共css */
page{
	font-size: 18px;
}
@import "common/css/form.less";
</style>
